package com.china.zhuoyue.ui.activity.estate.home.service

import androidx.recyclerview.widget.LinearLayoutManager
import com.china.zhuoyue.databinding.ActivityCommunityNoticeBinding
import com.china.zhuoyue.databinding.ItemCommunityNoticeBinding
import com.china.zhuoyue.ui.base.BaseActivity
import com.china.zhuoyue.ui.base.BaseRecyclerAdapter
import com.china.zhuoyue.ui.base.BaseViewHolder

class CommunityNoticeActivity : BaseActivity<ActivityCommunityNoticeBinding>() {
    override fun initView() {
        loadView {
            rvNotice.adapter = CommunityNoticeAdapter().apply {
                datas = CommunityNoticeAdapter.NOTICE
            }
            rvNotice.layoutManager = LinearLayoutManager(mThis)
        }
    }
}

data class CommunityNotice(
    val time: String,
    val title: String,
    val desc: String,
)

class CommunityNoticeAdapter : BaseRecyclerAdapter<BaseViewHolder<ItemCommunityNoticeBinding>, CommunityNotice>() {
    companion object {
        val NOTICE = mutableListOf<CommunityNotice>().apply {
            add(CommunityNotice("2021-5-9 15:10:20", "刚刚,人民日报公布1张照片，震惊国人！", "疫情下老百姓的人生百态"))
            add(CommunityNotice("2021-6-1 09:12:44", "疫情防控通知", "6.3日起，小区需持48H有效核酸检查证明方可进入，所有快递，送餐均放置统一点"))
        }
    }

    override fun onBindViewHolder(holder: BaseViewHolder<ItemCommunityNoticeBinding>, bean: CommunityNotice, position: Int) {
        holder.vb.apply {
            bean.apply {
                tvTime.text = time
                tvTitle.text = title
                tvDesc.text = desc
            }
        }
    }
}